"""
Base embedder interface and common classes.
"""

from abc import ABC, abstractmethod
from typing import List, Optional, Dict, Any, Literal
from dataclasses import dataclass

DocumentType = Literal["code", "text"]
TaskType = Literal["retrieval_query", "retrieval_document"]


@dataclass
class EmbeddingResponse:
    """Response from embedding API."""
    embeddings: List[List[float]]
    usage: Optional[Dict[str, int]] = None


@dataclass 
class EmbedderInfo:
    """Information about the embedder."""
    name: str


class IEmbedder(ABC):
    """Abstract base class for embedders."""
    
    @abstractmethod
    async def create_embeddings(
        self, 
        texts: List[str], 
        doc_type: DocumentType = "text", 
        task: TaskType = "retrieval_document"
    ) -> EmbeddingResponse:
        """Create embeddings for given texts."""
        pass
    
    @abstractmethod 
    async def validate_configuration(self) -> tuple[bool, Optional[str]]:
        """Validate the embedder configuration."""
        pass
    
    @property
    @abstractmethod
    def embedder_info(self) -> EmbedderInfo:
        """Get embedder information."""
        pass